package com.le.tester.imooc.masterJUC.threadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * 描述：定时的线程池，周期性的执行任务
 */
public class ScheduledThreadPoolTester {
    public static void main(String[] args) {
        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(10);
//        for (int i = 0; i < 100; i++) {
            //延迟五秒去执行任务，并没周期性的执行
            //executorService.schedule(new Task(), 5, TimeUnit.SECONDS);
            //周期性的执行5秒
            executorService.scheduleAtFixedRate(new Task(), 1, 5, TimeUnit.SECONDS);
//        }
    }
}
